package com.platform.demo;

import com.platform.api.Job;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import org.springframework.context.ApplicationContext;

public class PlatformContext {

  private static final Map<String, JobWrapper> jobs = new ConcurrentHashMap<>();

  public static void add(String jobId, JobWrapper jobWrapper) {
    jobs.put(jobId, jobWrapper);
  }


  public static JobWrapper getJobWrapper(String jobId) {
    return jobs.get(jobId);
  }

  @AllArgsConstructor
  @Getter
  public static class JobWrapper {

    private String jobId;
    @Setter
    private Job job;
    private String jobClass;
    private ClassLoader classLoader;
    private ApplicationContext context;
  }
}
